package com.pr.makfilm.domain;

import org.hibernate.validator.constraints.Length;

import javax.persistence.*;
import javax.validation.constraints.NotNull;

/**
 * Created with IntelliJ IDEA.
 * User: Pawel
 * Date: 10.09.13
 * Time: 22:42
 * To change this template use File | Settings | File Templates.
 */
@Entity
@Table(name = "school")
public class School extends IdentifiableEntity
{
   public static final String FIELD_NAME = "name";

   public static final String FIELD_TYPE = "type";

   public static final String FIELD_USER = "user";

   public static final String FIELD_STREET = "street";

   public static final String FIELD_ZIP = "zip";

   public static final String FIELD_CITY = "city";

   public static final String FIELD_DISTRICT = "district";

   public static final int MAX_LENGTH_NAME = 100;

   public static final int MAX_LENGTH_STREET = 35;

   public static final int MAX_LENGTH_ZIP = 6;

   public static final int MAX_LENGTH_CITY = 30;

   @Id
   @GeneratedValue
   @Column
   private Long id;

   @Column(nullable = false, length = MAX_LENGTH_NAME)
   @NotNull
   @Length(max = MAX_LENGTH_NAME)
   private String name;

   @ManyToOne(cascade = {CascadeType.MERGE, CascadeType.PERSIST}, fetch = FetchType.EAGER)
   @JoinColumn(nullable = false)
   @NotNull
   private SchoolType type;

   @ManyToOne(cascade = {CascadeType.MERGE, CascadeType.PERSIST}, fetch = FetchType.LAZY)
   @JoinColumn(nullable = false)
   @NotNull
   private User user;

   @Column(nullable = false, length = MAX_LENGTH_STREET)
   @NotNull
   @Length(max = MAX_LENGTH_STREET)
   private String street;

   @Column(nullable = false, length = MAX_LENGTH_ZIP)
   @NotNull
   @Length(max = MAX_LENGTH_ZIP)
   private String zip;

   @Column(nullable = false, length = MAX_LENGTH_CITY)
   @NotNull
   @Length(max = MAX_LENGTH_CITY)
   private String city;

   @ManyToOne(cascade = {CascadeType.MERGE, CascadeType.PERSIST}, fetch = FetchType.EAGER)
   @JoinColumn(nullable = false)
   @NotNull
   private District district;

   public Long getId()
   {
      return id;
   }

   public void setId(Long id)
   {
      this.id = id;
   }

   public String getName()
   {
      return name;
   }

   public void setName(String name)
   {
      this.name = name;
   }

   public SchoolType getType()
   {
      return type;
   }

   public void setType(SchoolType type)
   {
      this.type = type;
   }

   public User getUser()
   {
      return user;
   }

   public void setUser(User user)
   {
      this.user = user;
   }

   public String getStreet()
   {
      return street;
   }

   public void setStreet(String street)
   {
      this.street = street;
   }

   public String getZip()
   {
      return zip;
   }

   public void setZip(String zip)
   {
      this.zip = zip;
   }

   public String getCity()
   {
      return city;
   }

   public void setCity(String city)
   {
      this.city = city;
   }

   public District getDistrict()
   {
      return district;
   }

   public void setDistrict(District district)
   {
      this.district = district;
   }
}